<template>
    <div>
      <div class="fixed-top">
        <div class="top">
          <div @click="backHome">
            <i class="el-icon-arrow-left icon"></i>
          </div>
          <div class="top-title">错题库</div>
        </div>
      </div>
      <div class="tip" v-for = "item of errorTip" :key = "item.id" ref = "errorTip">
        <div class="tip-left">{{item.name}}</div>
        <div class="tip-desc">属于</div>
        <div class="tip-right">{{item.type}}</div>
      </div>
    </div>
</template>

<script>
import { getLocalStorage } from '../../utils/localStorage'

export default {
  data () {
    return {
      errorTip: []
    }
  },
  methods: {
    backHome () {
      window.history.go(-1)
    }
  },
  mounted () {
    console.log('error page')
    let sessionId = getLocalStorage('sessionId')
    this.$axios({
      methods: 'get',
      url: '/rubbish/wrongQuestion',
      headers: {'sessionId': sessionId}}
    ).then((res) => {
      console.log(res)
      if ((res.status === 200) && res.data.data) {
        res = res.data.data
        this.errorTip = res
      }
      console.log(this.errorTip, 'errorTip')
    })
  }
}
</script>

<style lang="scss" scoped>
@import "../../assets/styles/global";
.fixed-top {
  height: 45px;
  .top{
    position: fixed;
    top: 0;
    display: flex;
    width: 100%;
    height: 45px;
    line-height: 45px;
    text-align: center;
    font-size: 17px;
    background: skyblue;
    .icon{
      float: left;
      width: 50%;
      overflow: hidden;
      font-size: 20px;
      margin-left: 10px;
    }
    .top-title{
      flex: 1;
      margin-right: 45px;
    }
  }
}

.tip{
  display: flex;
  height: .9rem;
  line-height: .9rem;
  width: 96%;
  margin: .2rem auto;
  background: white;
  text-align: center;
  border-radius: 10px;
  .tip-left{
    width: 35%;
    float: left;
  }
  .tip-desc{
    flex: 1;
  }
  .tip-right{
    width: 35%;
    float: right;
  }
}
</style>
